package com.pingan.controller;

import com.pingan.pojo.NoticeType;
import com.pingan.pojo.Notices;
import com.pingan.service.NoticeService;
import com.pingan.util.PageUtil;
import com.pingan.util.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/notices")
public class NoticesController {
    @Autowired
    private NoticeService noticeService;

    @GetMapping("/list")
    public RespResult<List<Notices>> getNoticeList(@RequestBody Notices req){
        return new RespResult(PageUtil.startPage().doSelectPageInfo(
                ()->noticeService.getNoticeList(req)));
    }

    @PostMapping("/doAddNotice")
    public RespResult doAddNotice(@RequestBody Notices req){
        return new RespResult<>(noticeService.doAddNotice(req));
    }

    @DeleteMapping("/doDelNotice")
    public RespResult doDelNotice(@PathVariable Integer[] ids){
        return new RespResult<>(noticeService.doDelNotice(ids));
    }

    @PostMapping("/doUpdateNotice")
    public RespResult doUpdateNotice(@RequestBody Notices req){
        return new RespResult<>(noticeService.doUpdateNotice(req));
    }

    @GetMapping("/getNoticeType")
    public RespResult<List<NoticeType>> getNoticeType(){
        return new RespResult<>(noticeService.getNoticeType());
    }
}
